package com.irssproject.app.web.interceptor;

import java.util.Map;

import com.irssproject.app.utils.Constants;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class AutoritzacioInterceptor extends AbstractInterceptor{

	private static final long serialVersionUID = -9199166861711990575L;

	public String intercept(ActionInvocation invocation) throws Exception {

		Map session = ActionContext.getContext().getSession();

		if (session.containsKey(Constants.SESSIO_USUARI_AUTENTICAT)){
			invocation.invoke();
			return Action.SUCCESS;			
		}
		else{
			/*
			Object action = invocation.getAction ();
            if (action instanceof ValidationAware) {
                ((ValidationAware) action).addActionError ("Estas intentant accedir al sistema sense haver introduit el login i el password. Molt malament.");
            }
            */
            return "noAutenticat";

		}
	}

	
	
}
